package gui;

// Fritt att ändras, Ska bara en JPanel men lämplig representation och on click interaktion.

import domain.GameGrid;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.Insets;
import javax.swing.*;

// Man ska kuna returna en x,y kordinat om vart man tryckte.
// Skall även kunna printa ut boarden utifrån en 8x8 matris.
// Player 0 = orörd, 1 = vit, Player 2 = svart, 

public class GameBoard extends JPanel{
    
    private JButton board[][] = new JButton[8][8];
    
    private ImageIcon black = new ImageIcon();
    private ImageIcon white = new ImageIcon();
    private ImageIcon empty = new ImageIcon();

    public GameBoard(GameGrid grid) {
        
        setLayout(new GridBagLayout());
        GridBagConstraints gc = new GridBagConstraints();
        gc.weightx = 1d; 
        gc.weighty = 1d;
        gc.insets = new Insets(0, 0, 0, 0);//top, left, bottom, and right 
        gc.fill = GridBagConstraints.BOTH; 

        JLabel[][] label;    
    
        setLayout(new GridLayout(8, 8));
        
        // Paints current gamegrid status.
        for(int x = 0; x < 8; x++){
            for(int y = 0; y < 8; y++){
                if(grid.GameGrid[x][y].getOwner() == 0){
                    add(new JButton(" 0 "));
                }
                if(grid.GameGrid[x][y].getOwner() == 1){
                   add(new JButton(" 1 "));
                }
                if(grid.GameGrid[x][y].getOwner() == 2){
                    add(new JButton(" 2 "));
                }
            }
        }
        // Actionlisteners
        
        
        
        setVisible(true);
   }
    
}
